import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// 导入全局样式表
import './assets/css/global.css'
// 导入字体图标
import './assets/download/font_2008828_yz5l4oqjqmg/iconfont.css'
import axios from 'axios'
// 配置请求根路径
axios.defaults.baseURL = 'https://www.liulongbin.top:8888/api/private/v1/'
// axios请求拦截
axios.interceptors.request.use(config => {
  console.log(config)
  // 为请求头对象,添加Token验证Authorization字段
  config.headers.Authorization = window.sessionStorage.getItem('token')
  // 必须返回config
  return config
})
Vue.prototype.$http = axios
Vue.config.productionTip = false
// 全局时间过滤器
Vue.filter('dateFormat', function (originVal) {
  const date = new Date(originVal)
  // 获取年月日时分秒
  const year = date.getFullYear()
  const month = (date.getMonth() + 1 + '').padStart(2, '0')
  const datE = (date.getDate() + '').padStart(2, '0')
  const hour = (date.getHours() + '').padStart(2, '0')
  const minutes = (date.getMinutes() + '').padStart(2, '0')
  const seconds = (date.getSeconds() + '').padStart(2, '0')
  // 返回时间格式
  return `${year}-${month}-${datE} ${hour}:${minutes}:${seconds}`
})
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
